﻿
namespace Indeco.G24.Windows.Forms
{
	/// <summary>
	/// abstract SanPham typed datagridview
	/// </summary>
	[System.ComponentModel.DesignerCategoryAttribute("code")]
	public abstract class SanPhamDataGridViewBase : System.Windows.Forms.UserControl
	{	
		/// <summary> 
		/// Thrown when the current Entity changed.
		/// </summary>
		public event System.EventHandler<SanPhamDataGridViewEventArgs> CurrentEntityChanged;
		
		#region Fields
				
		/// <summary> 
		/// the current entity.
		/// </summary>
		private Entities.SanPham _currentSanPham = null;
		//private Dictionary<string, string> _columnsHeaders = new Dictionary<string, string>();
		
		/// <summary> 
		/// the datagridview instance
		/// </summary>
		protected System.Windows.Forms.DataGridView uxSanPhamDataGridView;
		
		/// <summary> 
		/// the errorprovider
		/// </summary>
		protected System.Windows.Forms.ErrorProvider uxSanPhamErrorProvider;
		
		/// <summary> 
		/// the bindingsource
		/// </summary>
		protected System.Windows.Forms.BindingSource uxSanPhamBindingSource;
		
		
		/// <summary> 
		/// the DGV column associated with the IDSanPham property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxIDSanPhamDataGridViewColumn;
		/// <summary> 
		/// the DGV column associated with the IDSanPhamDanhMuc property
		/// </summary>
		protected System.Windows.Forms.DataGridViewComboBoxColumn uxIDSanPhamDanhMucDataGridViewColumn;
		/// <summary> 
		/// the DGV column associated with the NhaCungCap property
		/// </summary>
		protected System.Windows.Forms.DataGridViewComboBoxColumn uxNhaCungCapDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Ten property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxTenDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the MoTa property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxMoTaDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the NhaSanXuat property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxNhaSanXuatDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the DonViTinh property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxDonViTinhDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the HinhMinhHoa property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxHinhMinhHoaDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the TrangThai property
		/// </summary>
		protected System.Windows.Forms.DataGridViewCheckBoxColumn uxTrangThaiDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the ViTri property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxViTriDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the SoLanXem property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxSoLanXemDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the ThoiDiemChinhSua property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxThoiDiemChinhSuaDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the ThoiDiemCapNhat property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxThoiDiemCapNhatDataGridViewColumn;
		
		#endregion
					
		#region Combo list
		
				
		private Entities.TList<Entities.SanPhamDanhMuc> _IDSanPhamDanhMucList;
		
		/// <summary> 
		/// The list of selectable SanPhamDanhMuc
		/// </summary>
		[System.ComponentModel.Category("DropDownList BindingSources")]
		public Entities.TList<Entities.SanPhamDanhMuc> IDSanPhamDanhMucList
		{
			get {return this._IDSanPhamDanhMucList;}
			set 
			{
				this._IDSanPhamDanhMucList = value;
				this.uxIDSanPhamDanhMucDataGridViewColumn.DataSource = null;
				this.uxIDSanPhamDanhMucDataGridViewColumn.DataSource = this._IDSanPhamDanhMucList;
			}
		}
		
		private bool _allowNewItemInIDSanPhamDanhMucList;
		
		/// <summary> 
		/// Indicates if user can add an item in the list of SanPhamDanhMuc
		/// </summary>
		[System.ComponentModel.Category(".netTiers"), System.ComponentModel.Description("Indicates if end user can add a new item in the combobox. an event will be thrown then.")]
		public bool AllowNewItemInIDSanPhamDanhMucList
		{
			get { return _allowNewItemInIDSanPhamDanhMucList;}
			set
			{
				this._allowNewItemInIDSanPhamDanhMucList = value;
				this.uxIDSanPhamDanhMucDataGridViewColumn.DisplayStyle = value ? System.Windows.Forms.DataGridViewComboBoxDisplayStyle.ComboBox : System.Windows.Forms.DataGridViewComboBoxDisplayStyle.DropDownButton;
			}
		}
		
				
		private Entities.TList<Entities.NhaCungCap> _NhaCungCapList;
		
		/// <summary> 
		/// The list of selectable NhaCungCap
		/// </summary>
		[System.ComponentModel.Category("DropDownList BindingSources")]
		public Entities.TList<Entities.NhaCungCap> NhaCungCapList
		{
			get {return this._NhaCungCapList;}
			set 
			{
				this._NhaCungCapList = value;
				this.uxNhaCungCapDataGridViewColumn.DataSource = null;
				this.uxNhaCungCapDataGridViewColumn.DataSource = this._NhaCungCapList;
			}
		}
		
		private bool _allowNewItemInNhaCungCapList;
		
		/// <summary> 
		/// Indicates if user can add an item in the list of NhaCungCap
		/// </summary>
		[System.ComponentModel.Category(".netTiers"), System.ComponentModel.Description("Indicates if end user can add a new item in the combobox. an event will be thrown then.")]
		public bool AllowNewItemInNhaCungCapList
		{
			get { return _allowNewItemInNhaCungCapList;}
			set
			{
				this._allowNewItemInNhaCungCapList = value;
				this.uxNhaCungCapDataGridViewColumn.DisplayStyle = value ? System.Windows.Forms.DataGridViewComboBoxDisplayStyle.ComboBox : System.Windows.Forms.DataGridViewComboBoxDisplayStyle.DropDownButton;
			}
		}
		
		#endregion
		
		#region Main Datasource
		
		private Entities.TList<Entities.SanPham> _SanPhamList;
				
		/// <summary> 
		/// The list of SanPham to be displayed in the DGV.
		/// </summary>
		[System.ComponentModel.Category("Data")]
		public Entities.TList<Entities.SanPham> SanPhamList
		{
			get {return this._SanPhamList;}
			set
			{
				this._SanPhamList = value;
				this.uxSanPhamBindingSource.DataSource = null;
				this.uxSanPhamBindingSource.DataSource = value;
				this.uxSanPhamDataGridView.DataSource = null;
				this.uxSanPhamDataGridView.DataSource = this.uxSanPhamBindingSource;				
				//this.uxSanPhamBindingSource.ListChanged += new System.ComponentModel.ListChangedEventHandler(uxSanPhamBindingSource_ListChanged);
				this.uxSanPhamBindingSource.CurrentItemChanged += new System.EventHandler(OnSanPhamBindingSourceCurrentItemChanged);
			}
		}
		
		private void OnSanPhamBindingSourceCurrentItemChanged(object sender, System.EventArgs e)
		{
			_currentSanPham = uxSanPhamBindingSource.Current as Entities.SanPham;
			
			if (_currentSanPham != null)
			{
				_currentSanPham.Validate();
			}
			//_SanPham.Validate();
			OnCurrentEntityChanged();
		}

		//void uxSanPhamBindingSource_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
		//{
			//throw new Exception("The method or operation is not implemented.");
		//}		
		
		#endregion
		
		/// <summary>
		/// Gets the currently selected <c cref="Entities.SanPham"/> instance.
		/// </summary>
		public Entities.SanPham SelectedSanPham
		{
			get {return this._currentSanPham;}
		}
		
		#region other properties
		
		/// <summary>
		/// Gets or sets a value indicating whether you have provided your own data-management operations for the DataGridView control.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool VirtualMode
		{
			get {return this.uxSanPhamDataGridView.VirtualMode;}
			set
			{
				this.uxSanPhamDataGridView.VirtualMode = value;
			}
		}
		
		/// <summary>
		/// Gets or sets a value indicating whether the option to add rows is displayed to the user.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool AllowUserToAddRows
		{
			get {return this.uxSanPhamDataGridView.AllowUserToAddRows;}
			set {this.uxSanPhamDataGridView.AllowUserToAddRows = value;}
		}
		
		/// <summary>
		/// Gets or sets a value indicating whether the user is allowed to delete rows from the DataGridView.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool AllowUserToDeleteRows
		{
			get {return this.uxSanPhamDataGridView.AllowUserToDeleteRows;}
			set {this.uxSanPhamDataGridView.AllowUserToDeleteRows = value;}
		}
		
		/// <summary>
		/// Gets the <c cref="DataGridView"/> instance.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public System.Windows.Forms.DataGridView DataGridView
		{
			get {return this.uxSanPhamDataGridView;}
		}
		
		/// <summary>
		/// Gets a collection that contains all the columns in the control.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]		
		[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Visible)]
		//[System.ComponentModel.EditorAttribute("System.Windows.Forms.Design.DataGridViewColumnCollectionEditor, System.Design", typeof(System.Drawing.Design.UITypeEditor))] 
		public System.Windows.Forms.DataGridViewColumnCollection Columns
		{
			get { return this.uxSanPhamDataGridView.Columns; }
		}
		
		#endregion
		
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;
	
		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing && (components != null))
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}
	
		#region Constructor
	
		/// <summary>
		/// Initializes a new instance of the <see cref="SanPhamDataGridViewBase"/> class.
		/// </summary>
		public SanPhamDataGridViewBase()
		{			
			this.components = new System.ComponentModel.Container();			
			
			this.uxSanPhamDataGridView = new System.Windows.Forms.DataGridView();
			this.uxSanPhamBindingSource = new System.Windows.Forms.BindingSource(this.components);
			this.uxSanPhamErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
			this.uxIDSanPhamDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxIDSanPhamDanhMucDataGridViewColumn = new System.Windows.Forms.DataGridViewComboBoxColumn();
			this.uxNhaCungCapDataGridViewColumn = new System.Windows.Forms.DataGridViewComboBoxColumn();
			this.uxTenDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxMoTaDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxNhaSanXuatDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxDonViTinhDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxHinhMinhHoaDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxTrangThaiDataGridViewColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
			this.uxViTriDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxSoLanXemDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxThoiDiemChinhSuaDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxThoiDiemCapNhatDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			//this.uxIDSanPhamDanhMucBindingSource = new SanPhamDanhMucBindingSource(this.components);
			//((System.ComponentModel.ISupportInitialize)(this.uxIDSanPhamDanhMucBindingSource)).BeginInit();
			//this.uxNhaCungCapBindingSource = new NhaCungCapBindingSource(this.components);
			//((System.ComponentModel.ISupportInitialize)(this.uxNhaCungCapBindingSource)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxSanPhamDataGridView)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxSanPhamBindingSource)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxSanPhamErrorProvider)).BeginInit();
			this.SuspendLayout();
						
			// 
			// uxSanPhamErrorProvider
			// 
			this.uxSanPhamErrorProvider.ContainerControl = this;
			this.uxSanPhamErrorProvider.DataSource = this.uxSanPhamBindingSource;						
			// 
			// uxSanPhamDataGridView
			// 
			this.uxSanPhamDataGridView.AutoGenerateColumns = false;
			this.uxSanPhamDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
			this.uxSanPhamDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
		this.uxIDSanPhamDataGridViewColumn,
		this.uxIDSanPhamDanhMucDataGridViewColumn,
		this.uxNhaCungCapDataGridViewColumn,
		this.uxTenDataGridViewColumn,
		this.uxMoTaDataGridViewColumn,
		this.uxNhaSanXuatDataGridViewColumn,
		this.uxDonViTinhDataGridViewColumn,
		this.uxHinhMinhHoaDataGridViewColumn,
		this.uxTrangThaiDataGridViewColumn,
		this.uxViTriDataGridViewColumn,
		this.uxSoLanXemDataGridViewColumn,
		this.uxThoiDiemChinhSuaDataGridViewColumn,
		this.uxThoiDiemCapNhatDataGridViewColumn			});
			this.uxSanPhamDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
			this.uxSanPhamDataGridView.Location = new System.Drawing.Point(0, 0);
			this.uxSanPhamDataGridView.Name = "uxSanPhamDataGridView";
			this.uxSanPhamDataGridView.Size = new System.Drawing.Size(470, 300);
			this.uxSanPhamDataGridView.TabIndex = 0;	
			this.uxSanPhamDataGridView.BackgroundColor = System.Drawing.Color.WhiteSmoke;
			this.uxSanPhamDataGridView.EnableHeadersVisualStyles = false;
			this.uxSanPhamDataGridView.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.OnSanPhamDataGridViewDataError);
			this.uxSanPhamDataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.OnSanPhamDataGridViewCellValueNeeded);
			this.uxSanPhamDataGridView.CellValuePushed += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.OnSanPhamDataGridViewCellValuePushed);
			
			//
			// uxIDSanPhamDataGridViewColumn
			//
			this.uxIDSanPhamDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxIDSanPhamDataGridViewColumn.DataPropertyName = "IDSanPham";
			this.uxIDSanPhamDataGridViewColumn.HeaderText = "IDSanPham";
			this.uxIDSanPhamDataGridViewColumn.Name = "uxIDSanPhamDataGridViewColumn";
			this.uxIDSanPhamDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxIDSanPhamDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxIDSanPhamDataGridViewColumn.ReadOnly = false;		
			//
			// uxIDSanPhamDanhMucDataGridViewColumn
			//
			this.uxIDSanPhamDanhMucDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxIDSanPhamDanhMucDataGridViewColumn.DataPropertyName = "IDSanPhamDanhMuc";
			this.uxIDSanPhamDanhMucDataGridViewColumn.HeaderText = "IDSanPhamDanhMuc";
			this.uxIDSanPhamDanhMucDataGridViewColumn.Name = "uxIDSanPhamDanhMucDataGridViewColumn";
			this.uxIDSanPhamDanhMucDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxIDSanPhamDanhMucDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxIDSanPhamDanhMucDataGridViewColumn.ReadOnly = false;		
			//
			// uxNhaCungCapDataGridViewColumn
			//
			this.uxNhaCungCapDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxNhaCungCapDataGridViewColumn.DataPropertyName = "NhaCungCap";
			this.uxNhaCungCapDataGridViewColumn.HeaderText = "NhaCungCap";
			this.uxNhaCungCapDataGridViewColumn.Name = "uxNhaCungCapDataGridViewColumn";
			this.uxNhaCungCapDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxNhaCungCapDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxNhaCungCapDataGridViewColumn.ReadOnly = false;		
			//
			// uxTenDataGridViewColumn
			//
			this.uxTenDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxTenDataGridViewColumn.DataPropertyName = "Ten";
			this.uxTenDataGridViewColumn.HeaderText = "Ten";
			this.uxTenDataGridViewColumn.Name = "uxTenDataGridViewColumn";
			this.uxTenDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxTenDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxTenDataGridViewColumn.ReadOnly = false;		
			//
			// uxMoTaDataGridViewColumn
			//
			this.uxMoTaDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxMoTaDataGridViewColumn.DataPropertyName = "MoTa";
			this.uxMoTaDataGridViewColumn.HeaderText = "MoTa";
			this.uxMoTaDataGridViewColumn.Name = "uxMoTaDataGridViewColumn";
			this.uxMoTaDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxMoTaDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxMoTaDataGridViewColumn.ReadOnly = false;		
			//
			// uxNhaSanXuatDataGridViewColumn
			//
			this.uxNhaSanXuatDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxNhaSanXuatDataGridViewColumn.DataPropertyName = "NhaSanXuat";
			this.uxNhaSanXuatDataGridViewColumn.HeaderText = "NhaSanXuat";
			this.uxNhaSanXuatDataGridViewColumn.Name = "uxNhaSanXuatDataGridViewColumn";
			this.uxNhaSanXuatDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxNhaSanXuatDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxNhaSanXuatDataGridViewColumn.ReadOnly = false;		
			//
			// uxDonViTinhDataGridViewColumn
			//
			this.uxDonViTinhDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxDonViTinhDataGridViewColumn.DataPropertyName = "DonViTinh";
			this.uxDonViTinhDataGridViewColumn.HeaderText = "DonViTinh";
			this.uxDonViTinhDataGridViewColumn.Name = "uxDonViTinhDataGridViewColumn";
			this.uxDonViTinhDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxDonViTinhDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxDonViTinhDataGridViewColumn.ReadOnly = false;		
			//
			// uxHinhMinhHoaDataGridViewColumn
			//
			this.uxHinhMinhHoaDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxHinhMinhHoaDataGridViewColumn.DataPropertyName = "HinhMinhHoa";
			this.uxHinhMinhHoaDataGridViewColumn.HeaderText = "HinhMinhHoa";
			this.uxHinhMinhHoaDataGridViewColumn.Name = "uxHinhMinhHoaDataGridViewColumn";
			this.uxHinhMinhHoaDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxHinhMinhHoaDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxHinhMinhHoaDataGridViewColumn.ReadOnly = false;		
			//
			// uxTrangThaiDataGridViewColumn
			//
			this.uxTrangThaiDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxTrangThaiDataGridViewColumn.DataPropertyName = "TrangThai";
			this.uxTrangThaiDataGridViewColumn.HeaderText = "TrangThai";
			this.uxTrangThaiDataGridViewColumn.Name = "uxTrangThaiDataGridViewColumn";
			this.uxTrangThaiDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxTrangThaiDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxTrangThaiDataGridViewColumn.ReadOnly = false;		
			//
			// uxViTriDataGridViewColumn
			//
			this.uxViTriDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxViTriDataGridViewColumn.DataPropertyName = "ViTri";
			this.uxViTriDataGridViewColumn.HeaderText = "ViTri";
			this.uxViTriDataGridViewColumn.Name = "uxViTriDataGridViewColumn";
			this.uxViTriDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxViTriDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxViTriDataGridViewColumn.ReadOnly = false;		
			//
			// uxSoLanXemDataGridViewColumn
			//
			this.uxSoLanXemDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxSoLanXemDataGridViewColumn.DataPropertyName = "SoLanXem";
			this.uxSoLanXemDataGridViewColumn.HeaderText = "SoLanXem";
			this.uxSoLanXemDataGridViewColumn.Name = "uxSoLanXemDataGridViewColumn";
			this.uxSoLanXemDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxSoLanXemDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxSoLanXemDataGridViewColumn.ReadOnly = false;		
			//
			// uxThoiDiemChinhSuaDataGridViewColumn
			//
			this.uxThoiDiemChinhSuaDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxThoiDiemChinhSuaDataGridViewColumn.DataPropertyName = "ThoiDiemChinhSua";
			this.uxThoiDiemChinhSuaDataGridViewColumn.HeaderText = "ThoiDiemChinhSua";
			this.uxThoiDiemChinhSuaDataGridViewColumn.Name = "uxThoiDiemChinhSuaDataGridViewColumn";
			this.uxThoiDiemChinhSuaDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxThoiDiemChinhSuaDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxThoiDiemChinhSuaDataGridViewColumn.ReadOnly = false;		
			//
			// uxThoiDiemCapNhatDataGridViewColumn
			//
			this.uxThoiDiemCapNhatDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxThoiDiemCapNhatDataGridViewColumn.DataPropertyName = "ThoiDiemCapNhat";
			this.uxThoiDiemCapNhatDataGridViewColumn.HeaderText = "ThoiDiemCapNhat";
			this.uxThoiDiemCapNhatDataGridViewColumn.Name = "uxThoiDiemCapNhatDataGridViewColumn";
			this.uxThoiDiemCapNhatDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxThoiDiemCapNhatDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxThoiDiemCapNhatDataGridViewColumn.ReadOnly = false;		
			//
			// uxIDSanPhamDanhMucDataGridViewColumn
			//				
			this.uxIDSanPhamDanhMucDataGridViewColumn.DisplayMember = "IDSanPhamDanhMucCha";	
			this.uxIDSanPhamDanhMucDataGridViewColumn.ValueMember = "IDSanPhamDanhMuc";	
			this.uxIDSanPhamDanhMucDataGridViewColumn.DisplayStyleForCurrentCellOnly = true;
			//uxIDSanPhamDanhMucDataGridViewColumn.DataSource = uxIDSanPhamDanhMucBindingSource;				
				
			//
			// uxNhaCungCapDataGridViewColumn
			//				
			this.uxNhaCungCapDataGridViewColumn.DisplayMember = "NhaCungCap";	
			this.uxNhaCungCapDataGridViewColumn.ValueMember = "IDNhaCungCap";	
			this.uxNhaCungCapDataGridViewColumn.DisplayStyleForCurrentCellOnly = true;
			//uxNhaCungCapDataGridViewColumn.DataSource = uxNhaCungCapBindingSource;				
				
			
			// this
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.Controls.Add(this.uxSanPhamDataGridView);
			this.Name = "SanPhamDataGridView";
			this.Size = new System.Drawing.Size(470, 300);
			//((System.ComponentModel.ISupportInitialize)(this.uxIDSanPhamDanhMucBindingSource)).EndInit();
			//((System.ComponentModel.ISupportInitialize)(this.uxNhaCungCapBindingSource)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxSanPhamErrorProvider)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxSanPhamDataGridView)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxSanPhamBindingSource)).EndInit();
			this.ResumeLayout(false);
		}
		#endregion
				
		#region events
		
		/// <summary>
		/// Raised the CurrentEntityChanged event.
		/// </summary>
		protected void OnCurrentEntityChanged()
		{
			if (CurrentEntityChanged != null)
			{
				SanPhamDataGridViewEventArgs args = new SanPhamDataGridViewEventArgs();
				args.SanPham = _currentSanPham;
				CurrentEntityChanged(this, args); 
			}
		}
		
		#endregion
		
		/// <summary>
		/// Strongly typed event 
		/// </summary>
		public class SanPhamDataGridViewEventArgs : System.EventArgs
		{
			private Entities.SanPham	_SanPham;
	
			/// <summary>
			/// the  Entities.SanPham instance.
			/// </summary>
			public Entities.SanPham SanPham
			{
				get { return _SanPham; }
				set { _SanPham = value; }
			}	
		}
		
		/// <summary>
		/// Handles the DataError event of the uxSanPhamDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewDataErrorEventArgs"/> instance containing the event data.</param>
		protected void OnSanPhamDataGridViewDataError(object sender, System.Windows.Forms.DataGridViewDataErrorEventArgs e)
		{
			System.Diagnostics.Debug.WriteLine(string.Format( "{0}, {1}", e.ColumnIndex, e.RowIndex));
		}
		
		/// <summary>
		/// Handles the CellValueNeeded event of the uxSanPhamDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewCellValueEventArgs"/> instance containing the event data.</param>
		protected void OnSanPhamDataGridViewCellValueNeeded(object sender, System.Windows.Forms.DataGridViewCellValueEventArgs e)
		{
			switch(uxSanPhamDataGridView.Columns[e.ColumnIndex].Name)
			{
					case "uxIDSanPhamDataGridViewColumn":
						e.Value = SanPhamList[e.RowIndex].IDSanPham;
						break;
					case "uxIDSanPhamDanhMucDataGridViewColumn":
						e.Value = SanPhamList[e.RowIndex].IDSanPhamDanhMuc;
						break;
					case "uxNhaCungCapDataGridViewColumn":
						e.Value = SanPhamList[e.RowIndex].NhaCungCap;
						break;
					case "uxTenDataGridViewColumn":
						e.Value = SanPhamList[e.RowIndex].Ten;
						break;
					case "uxMoTaDataGridViewColumn":
						e.Value = SanPhamList[e.RowIndex].MoTa;
						break;
					case "uxNhaSanXuatDataGridViewColumn":
						e.Value = SanPhamList[e.RowIndex].NhaSanXuat;
						break;
					case "uxDonViTinhDataGridViewColumn":
						e.Value = SanPhamList[e.RowIndex].DonViTinh;
						break;
					case "uxHinhMinhHoaDataGridViewColumn":
						e.Value = SanPhamList[e.RowIndex].HinhMinhHoa;
						break;
					case "uxTrangThaiDataGridViewColumn":
						e.Value = SanPhamList[e.RowIndex].TrangThai;
						break;
					case "uxViTriDataGridViewColumn":
						e.Value = SanPhamList[e.RowIndex].ViTri;
						break;
					case "uxSoLanXemDataGridViewColumn":
						e.Value = SanPhamList[e.RowIndex].SoLanXem;
						break;
					case "uxThoiDiemChinhSuaDataGridViewColumn":
						e.Value = SanPhamList[e.RowIndex].ThoiDiemChinhSua;
						break;
					case "uxThoiDiemCapNhatDataGridViewColumn":
						e.Value = SanPhamList[e.RowIndex].ThoiDiemCapNhat;
						break;
				default:
				break;
			}
		}
		
		/// <summary>
		/// Handles the CellValuePushed event of the uxSanPhamDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewCellValueEventArgs"/> instance containing the event data.</param>
		protected void OnSanPhamDataGridViewCellValuePushed(object sender, System.Windows.Forms.DataGridViewCellValueEventArgs e)
		{
			switch(uxSanPhamDataGridView.Columns[e.ColumnIndex].Name)
			{
					case "uxIDSanPhamDataGridViewColumn":
						SanPhamList[e.RowIndex].IDSanPham = (System.Guid)e.Value;
						break;
					case "uxIDSanPhamDanhMucDataGridViewColumn":
						SanPhamList[e.RowIndex].IDSanPhamDanhMuc = (System.Guid)e.Value;
						break;
					case "uxNhaCungCapDataGridViewColumn":
						SanPhamList[e.RowIndex].NhaCungCap = (System.String)e.Value;
						break;
					case "uxTenDataGridViewColumn":
						SanPhamList[e.RowIndex].Ten = (System.String)e.Value;
						break;
					case "uxMoTaDataGridViewColumn":
						SanPhamList[e.RowIndex].MoTa = (System.String)e.Value;
						break;
					case "uxNhaSanXuatDataGridViewColumn":
						SanPhamList[e.RowIndex].NhaSanXuat = (System.String)e.Value;
						break;
					case "uxDonViTinhDataGridViewColumn":
						SanPhamList[e.RowIndex].DonViTinh = (System.String)e.Value;
						break;
					case "uxHinhMinhHoaDataGridViewColumn":
						SanPhamList[e.RowIndex].HinhMinhHoa = (System.String)e.Value;
						break;
					case "uxTrangThaiDataGridViewColumn":
						SanPhamList[e.RowIndex].TrangThai = (System.Boolean)e.Value;
						break;
					case "uxViTriDataGridViewColumn":
						SanPhamList[e.RowIndex].ViTri = (System.Int64)e.Value;
						break;
					case "uxSoLanXemDataGridViewColumn":
						SanPhamList[e.RowIndex].SoLanXem = (System.Int64)e.Value;
						break;
					case "uxThoiDiemChinhSuaDataGridViewColumn":
						SanPhamList[e.RowIndex].ThoiDiemChinhSua = (System.DateTime?)e.Value;
						break;
					case "uxThoiDiemCapNhatDataGridViewColumn":
						SanPhamList[e.RowIndex].ThoiDiemCapNhat = (System.DateTime)e.Value;
						break;
				default:
				break;
			}
		}
	}
}
